package cn.edu.njupt.eclass.aixinling.service.Impl;

import cn.edu.njupt.eclass.aixinling.mapper.TagMapper;
import cn.edu.njupt.eclass.aixinling.model.Tag;
import cn.edu.njupt.eclass.aixinling.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: kent
 * @date: 2018/6/4 20:53
 */
@Service("TagService")
public class ITagService implements TagService {

    @Autowired
    TagMapper tagMapper;


    public List<Tag> getAll(){
        return tagMapper.selectAll();

    }


    /**
     * @param: null
     * @return Tag
     * @author Kent Lee
     * @date 2018/6/8 17:18
     * @Note: 获取表中最高权重的标签
     */
    public Tag getHighestWeightTag() {
        return tagMapper.getHighestWeightTag();
    }

    /**
     * @param: Integer
     * @return List<Tag>
     * @author Kent Lee
     * @date 2018/6/8 17:18
     * @Note: 获取指定数目的tag
     */
    public List<Tag> getTagsByNum(Integer num) {
        return tagMapper.getTagsByNum(num);
    }


    /**
     * @Description:
     * @Param: [id]
     * @return: int
     * @Author: Kent Lee
     * @Time: 2018/6/8 17:35
     */
    public int setTagUnpublishedById(Integer id) {
        return tagMapper.setTagUnpublishedById(id);

    }

    /** 
    * @Description: 发布 
    * @Param:  
    * @return:  
    * @Author: Kent Lee
    * @Time: 2018/6/8  17:39 
    */ 
    public int setTagPublishedById(Integer id) {
        return tagMapper.setTagPublishedById(id);
    }

    
    public int getStatusById(Integer id) {
        return tagMapper.getStatusById(id);
    }

    /** 
    * @Description:  
    * @Param:  
    * @return:  
    * @Author: Kent Lee
    * @Time: 2018/6/8  17:38 
    */ 
    public int setTagsTopById(Integer id) {
        return tagMapper.setTagsTopById(id);
    }
    
    /** 
    * @Description: 通过id获取tag 
    * @Param:  
    * @return:  
    * @Author: Kent Lee
    * @Time: 2018/6/8  18:36 
    */ 
    public Tag getTagById(Integer id) {
        return tagMapper.selectByPrimaryKey(id);
    }


    /** 
    * @Description: 更新tag 
    * @Param:  
    * @return:  
    * @Author: Kent Lee
    * @Time: 2018/6/8  18:36 
    */ 
    public int EditTagById(Tag tag) {
        return tagMapper.updateByPrimaryKey(tag);
    }

    /** 
    * @Description: 删除Tag 
    * @Param:  
    * @return:  
    * @Author: Kent Lee
    * @Time: 2018/6/8  18:37 
    */ 
    public int deleteById(Integer id){
        return tagMapper.deleteByPrimaryKey(id);
    }

    /** 
    * @Description: 新增Tag 
    * @Param:  
    * @return:
    * @Author: Kent Lee
    * @Time: 2018/6/8  18:44
    */ 
    public int addNewTag(Tag tag) {
        return tagMapper.insert(tag);
    }
}
